package edu.kjxy.day03.t9;

/**
 * 功能:脏读出现了，出现原因是两个线程 以异步的方式返回list参数的size()大小。解决办法就是同步化
 * 作者:程序员欧阳子韩
 * 日期:2024/2/2 19:23
 */
public class RunTest {
    public static void main(String[] args) throws InterruptedException {
        MyOneList list = new MyOneList();
        MyThread1 thread1 = new MyThread1(list);
        thread1.setName("A");
        thread1.start();
        MyThread2 thread2 = new MyThread2(list);
        thread2.setName("B");
        thread2.start();
        Thread.sleep(6000);
        System.out.println("listSize=" + list.getSize());
    }
}
